package com.doit.day06

object _01_minBy和maxBy {
  def main(args: Array[String]): Unit = {
    val tuples: List[(Int, String)] = List((1, "zss"), (2, "lss"), (3, "ww"))
    //获取元祖第一个元素的最大值的那个元祖
    val tuple: (Int, String) = tuples.maxBy(_._1)
    println(tuple)

    val list: List[LaoWang] = List(new LaoWang(1, "wang1", 18),
      new LaoWang(2, "wang1", 18),
      new LaoWang(1, "wang1", 18))

    val distinct: List[LaoWang] = list.distinct  //会用equals方法去比较
    distinct.foreach(println)//LaoWang(1,wang1,18)


/*
    val wang: LaoWang = list.maxBy(_.age)
    println(wang)


    val ints: List[String] = List("1", "2", "3", "4")

    val str: String = ints.reduce((a, b) => a +"_"+ b)//类似于mkString
    println(str)//1234*/


  }
}

case class LaoWang(id:Int,name:String,age:Int)
